<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryParams" v-show="showSearch" :inline="true"  >
      <el-form-item>
          <el-checkbox v-model="queryParams.startedByMe">我发起的</el-checkbox>
          <el-checkbox v-model="queryParams.ccToMe">抄送我</el-checkbox>
          <el-checkbox v-model="queryParams.unfinished">未办结</el-checkbox>
          <el-checkbox v-model="queryParams.finished">已办结</el-checkbox>
      </el-form-item>
       <el-form-item>
          <span style="margin-left:10px;">
          <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        </span>
      </el-form-item>
    </el-form>
    
    <el-table v-loading="loading" border :data="list"  >
      <el-table-column label="流程名称" prop="name" :show-overflow-tooltip="true"   />
      <el-table-column label="启动人" prop="startUserId" :show-overflow-tooltip="true"   />
      <el-table-column label="开始时间" prop="startTime" align="center" width="165px">
          <template slot-scope="scope"><span>{{ scope.row.startTime }}</span></template>
      </el-table-column>
      <el-table-column label="结束时间" prop="endTime" align="center" width="165px">
          <template slot-scope="scope"><span>{{ scope.row.endTime }}</span></template>
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
            <el-button 
              size="mini" 
              type="text" 
              icon="el-icon-edit" 
              @click="btnView(scope.row.id)"
            >查看</el-button>
            
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
     <process-detail v-if="dialogViewVisible" :visible.sync="dialogViewVisible"
                        :processInstanceId="processInstanceId"></process-detail>
  </div>
</template>

<script>
import { getlistByMyInvolved } from "@/api/flowable/instance";
import ProcessDetail from "../components/ProcessDetail";
export default {
  name: "model",
  components:{
    ProcessDetail
  },
  data() {
    return {
      dialogViewVisible:false,
      processInstanceId:undefined,
      selectedRecords: [],
      dialogStatus: '',
      dialogFormVisible:false,
      dialogImportVisible:false,
      modelCateOptions:[],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 表格数据
      list: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        startedByMe:false,
        ccToMe:false,
        unfinished:false,
        finished:false
      },
      temp: {
          id: undefined,
          key: '',
          name: '',
          category: '',
          description: '',
          tenantId: ''
      },
      rules: {
          id: [{required: true, message: '该项不能为空', trigger: 'change'}],
          key: [{required: true, message: '该项不能为空', trigger: 'change'}],
          name: [{required: true, message: '该项不能为空', trigger: 'change'}]
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
      this.getList();
      this.getDicts("model_cate").then((response) => {
        this.modelCateOptions = response.data;
      });
  
  },
  methods: {
     
    /** 查询列表 */
    getList() {
      this.loading = true;
      getlistByMyInvolved(this.queryParams).then(
        response => {
          this.list = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    btnView(processInstanceId) {
      console.log(processInstanceId)
        this.processInstanceId = processInstanceId
        this.dialogViewVisible = true
    }
    
  }
};
</script>